/**
 * 
 */
package com.netty.server.console;


import com.netty.coder.JSonStreamDecoder;
import com.netty.coder.JSonStreamEncoder;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;


/**
 * @author Lee
 *
 */
public class NettyServerInitializer  extends ChannelInitializer<SocketChannel> {
	@Override
    public void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        // Enable stream compression (you can remove these two if unnecessary)
        
        //pipeline.addLast("deflater", new DelphiZipEncoder());
        //pipeline.addLast("inflater", new DelphiZipDecoder());
        pipeline.addLast("timeout", new TimeOutKickHandler(0, 0, 60 * 5));
        
        // Add the number codec first,
        pipeline.addLast("decoder", new JSonStreamDecoder());
        pipeline.addLast("encoder", new JSonStreamEncoder());

        // and then business logic.
        // Please note we create a handler for every new channel
        // because it has stateful properties.
        pipeline.addLast("handler", new NettyServerHandler());
    }
}
